import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WorkCycleForm, WorkCycleQuery, WorkCycleVO } from './types';

/**
 * 查询工作循环信息列表
 * @param query
 * @returns {*}
 */

export const listWorkCycle = (query?: WorkCycleQuery): AxiosPromise<WorkCycleVO[]> => {
  return request({
    url: '/iot/workCycle/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工作循环信息详细
 * @param workCycleId
 */
export const getWorkCycle = (workCycleId: string | number): AxiosPromise<WorkCycleVO> => {
  return request({
    url: '/iot/workCycle/' + workCycleId,
    method: 'get'
  });
};

/**
 * 新增工作循环信息
 * @param data
 */
export const addWorkCycle = (data: WorkCycleForm) => {
  return request({
    url: '/iot/workCycle',
    method: 'post',
    data: data
  });
};

/**
 * 修改工作循环信息
 * @param data
 */
export const updateWorkCycle = (data: WorkCycleForm) => {
  return request({
    url: '/iot/workCycle',
    method: 'put',
    data: data
  });
};

/**
 * 删除工作循环信息
 * @param workCycleId
 */
export const delWorkCycle = (workCycleId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/workCycle/' + workCycleId,
    method: 'delete'
  });
};
